import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class PurchaseRecordPage extends StatefulWidget {
  PurchaseRecordPage({Key? key}) : super(key: key);

  @override
  State<PurchaseRecordPage> createState() => _PurchaseRecordPageState();
}

class _PurchaseRecordPageState extends State<PurchaseRecordPage> {
  bool isInitData = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('购券记录'),
        elevation: 0,
      ),
      backgroundColor: Colors.white,
      body: isInitData
          ? Center(
              child: CircularProgressIndicator(
                  value: null,
                  backgroundColor: Colors.red,
                  valueColor: AlwaysStoppedAnimation(Colors.blue)),
            )
          : Center(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  SizedBox(height: 120.h),
                  CachedNetworkImage(
                    imageUrl:
                        'https://amoy-ticket.oss-cn-nanjing.aliyuncs.com/people/coupon/empty_image.jpg',
                    fit: BoxFit.fill,
                    width: 150.w,
                  ),
                  SizedBox(height: 20.h),
                  Text(
                    '没有找到券包订单哦',
                    style: TextStyle(color: Colors.black, fontSize: 14.sp),
                  ),
                  SizedBox(height: 20.h),
                  GestureDetector(
                    onTap: () async {
                      setState(() {
                        isInitData = true;
                      });
                      await Future.delayed(Duration(milliseconds: 1000), () {
                        setState(() {
                          isInitData = false;
                        });
                      });
                    },
                    child: Container(
                      padding:
                          EdgeInsets.symmetric(horizontal: 12.w, vertical: 3.h),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20.r),
                        border: Border.all(width: 1, color: Colors.grey),
                      ),
                      child: Text(
                        '刷新页面',
                        style: TextStyle(fontSize: 11.sp),
                      ),
                    ),
                  ),
                ],
              ),
            ),
    );
  }
}
